<?php 
/*
$JA#COPYRIGHT$
*/

// no direct access

defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.model' );
require_once JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'jaconstants.php';
require_once JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'japermissions.php';
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'helper'.DS.'jafunctions.class.php');
require_once JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'rendfield.php';
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'helper'.DS.'jahelper.php');
global $jbconfig;
component_configs();
checkPermission('view_list_jobs');

$limit		= 	intval(trim( $params->get( 'number_items', 20 )));
$mode		= 	trim( $params->get( 'mode', 'a.effected_date desc' ) );
JHTML::_('behavior.tooltip');

require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'models'.DS.'jajobs.php');
require_once (dirname(__FILE__).DS.'helper.php');
// If the template has a css override use it

if(!defined('JAJOBBOARD_GLOBAL_CSS')){
	 global $mainframe;
	 if(file_exists(JPATH_BASE.DS.'templates/'.$mainframe->getTemplate().'/css/ja.jobboard.css')){
	 	JHTML::stylesheet('ja.jobboard.css', 'templates/'.$mainframe->getTemplate().'/css/');
	 }
	 else{
	 	JHTML::stylesheet('ja.jobboard.css', 'components/'. 'com_jajobboard' .'/css/');
	 }    	 	 	 
	 JHTML::script('ja.jobboard.js', 'components/com_jajobboard/js/');
	 JHTML::script('joomla.javascript.js', 'includes/js/');
	 
	 define('JAJOBBOARD_GLOBAL_CSS', 1);
} 
JHTML::stylesheet('', modJAListJobsHelper::getFile('ja.list_jobs.css','modules/mod_jalist_jobs/ja.list_jobs/','templates/'.$mainframe->getTemplate().'/css/'));


/**
* Require Cache 
* */
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'jacache'.DS.'jacache.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'jacache'.DS.'jajob.inc.php');
$cache = new JA_Cache($jbconfig['cache']->get('cache_base', JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'cache'), $jbconfig['cache']->get('cache_time', 5), $jbconfig['cache']->get('caching', true));
$cache_id = md5('mod_jalist_jobs');
$cache_group = 'jajobs';
if($cache->check_cache($cache_id, $cache_group)) return ;
else $oldlen = strlen(ob_get_contents());
/* End Cache */


global $mainframe;

$model = new JobBoardModelJAJobs();

$where_more = '';
if(!$mainframe->isAdmin()){
	$where_more = " and fl.admin_only!=1";
}

$this->allFields = $model->getEditFieldList(' and f.frontend_hidden=0 ');
$this->fieldlist = $model->getFieldList($where_more);

$this->all_items = modJAListJobsHelper::get_list_jobs($model, $limit, $mode);
$this->pagination = null;
$this->Itemid = modJAListJobsHelper::_findItem();

$path = JModuleHelper::getLayoutPath('mod_jalist_jobs', 'default');
if (file_exists($path)) {
	require($path);
}

/* Set Cache */
$maincontent = substr(ob_get_contents(), $oldlen);
if($maincontent){
	$cache->_cache->store($maincontent, $cache_id, $cache_group);		
}

?>